using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;

namespace SPDevExplorer
{
    internal class FileProperties : SharePointProperties
    {
        public FileProperties(TreeNode n) : base(n)
        {
        }

        public FileProperties(XmlElement xml) : base(xml)
        {
        }

        [Category("SharePoint"), ReadOnly(true)]
        public bool HasCheckedOut
        {
            get { return (Xml.GetAttribute("HasCheckedOut") == "True"); }
        }

        public string CheckedOutBy
        {
            get { return Xml.GetAttribute("CheckedOutBy"); }
        }

        public bool HasPublishedVersion
        {
            get { return (Xml.GetAttribute("HasPublishedVersion") == "True"); }
        }

        public bool CanModify
        {
            get { return HasCheckedOut; }
        }

        // Time last modified in SharePoint
        public DateTime TimeLastModified
        {
            get { return DateTime.Parse(Xml.GetAttribute("TimeLastModified")); }
        }

        /// <summary>
        /// Returns "Published", "Draft", ...
        /// </summary>
        public string Level
        {
            get { return Xml.GetAttribute("Level"); }
        }

        public bool IsInDraft
        {
            get { return (Xml.GetAttribute("Level") != "Published"); }
        }

        public string MajorVersion
        {
            get { return Xml.GetAttribute("MajorVersion"); }
        }

        public string MinorVersion
        {
            get { return Xml.GetAttribute("MinorVersion"); }
        }

        /// <summary>
        /// Returns "Approved", "Denied" or "Pending"
        /// </summary>
        public string ModerationStatus
        {
            get { return Xml.GetAttribute("ModerationStatus"); }
        }

    }
}